package tools

import (
	"context"
	"gorm.io/gorm/logger"
	"log"
	"os"
	"time"
)

func GetLogger() (logger.Interface, context.Context) {
	mLogger := logger.New(
		log.New(os.Stdout, "\r\n", log.LstdFlags),
		logger.Config{
			SlowThreshold:             time.Second * 3, // 慢 SQL 阈值：3S
			LogLevel:                  logger.Info,     // 日志级别
			IgnoreRecordNotFoundError: true,            // 忽略ErrRecordNotFound（记录未找到）错误
			Colorful:                  true,            // 彩色打印
		},
	)

	mCtx := context.Background()

	return mLogger, mCtx
}
